package com.groupscore.score.dao;

import com.groupscore.score.pojo.PersonalScore;
import com.groupscore.score.pojo.Score;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

public interface PersonalScoreDao extends JpaRepository<PersonalScore, String> {

    /**
     * 个人得分从高到低
     */
    @Query(value = "SELECT SUM(score)as score,personal_name as name from personal_score GROUP BY personal_name ORDER BY score desc", nativeQuery = true)
    public List<Map> personalScore();


    /**
     * 根据登录人id查询所打分的各个小组的各项总分
     */
    @Query(value = "SELECT score, personal_name as name from personal_score where user_id = ?", nativeQuery = true)
    public List<Map> groupScoreByUserId(String userId);
}
